package com.xcity.game.battle.pve.employee.impl;

import com.xcity.game.battle.pve.PlayerBattler;
import com.xcity.game.battle.pve.employee.EmployeeSkillBattleContext;
import com.xcity.game.employee.skill.EmployeeSkill;

//{2=90095#0}{3=90096#0}{4=90097#0}共同出场时，在玩家气势低于{0=50#0}%时攻击伤害提升{1=100#0}%
public class SKILL_39_CONTEXT extends EmployeeSkillBattleContext {

	private boolean triggered;
	private int playerInitAttack;
	
	public SKILL_39_CONTEXT(PlayerBattler player, EmployeeSkill ref) {
		super(player, ref);
		playerInitAttack = player.getAttack();
	}

	@Override
	public boolean trigger() {
		float obHp = ref.getTemplate().getInitVal(0) * player.getMaxHp() / 100;
		if (!triggered && player.getHp() < obHp) {
			triggered = true;
			player.setAttack((int) (player.getAttack() + player.getAttack() * ref.getTemplate().getInitVal(1) / 100));
		} else if (player.getHp() >= obHp) {
			triggered = false;
			player.setAttack(playerInitAttack);
		}
		return true;
	}

}
